<template>
  <div class="seckill-page">
    <!-- 头部标题 -->
    <div class="header">
      <h1 class="title">限时秒杀</h1>
      <div class="time">中国移动 下午4:40</div>
    </div>

    <!-- 时间轴 -->
    <el-tabs v-model="activeTime" class="time-line">
      <el-tab-pane
          v-for="(time, index) in timeSlots"
          :key="index"
          :name="time.time"
      >
        <template #label>
          <div class="time-tab">
            <div class="time-point">{{ time.time }}</div>
            <div class="status" :class="time.statusClass">{{ time.status }}</div>
          </div>
        </template>
      </el-tab-pane>
    </el-tabs>

    <!-- 实时热抢 -->
    <div class="hot-section">
      <h3 class="section-title">实时热抢</h3>
      <el-scrollbar>
        <div class="hot-items">
          <el-card
              v-for="(item, index) in hotProducts"
              :key="index"
              class="hot-item"
          >
            <img :src="item.image" class="product-img">
            <div class="product-name">{{ item.name }}</div>
            <div class="price-tag">
              <span class="price">￥{{ item.price }}</span>
              <el-tag type="danger" size="small">+{{ item.bonus }}</el-tag>
            </div>
          </el-card>
        </div>
      </el-scrollbar>
    </div>

    <!-- 热卖商品 -->
    <div class="product-list">
      <el-card
          v-for="(product, index) in products"
          :key="index"
          class="product-card"
      >
        <div class="product-header">
          <el-tag type="danger" effect="dark">热卖</el-tag>
          <div class="product-title">{{ product.title }}</div>
        </div>
        <div class="product-body">
          <div class="price-section">
            <span class="current-price">￥{{ product.price }}</span>
            <el-button type="danger" round size="small">立即抢购</el-button>
          </div>
          <div class="promotion-section">
            <el-tag type="warning">{{ product.promotion }}</el-tag>
            <el-progress
                :percentage="product.soldPercent"
                :show-text="false"
                status="exception"
                class="progress"
            />
            <span class="sold-text">已抢 {{ product.soldPercent }}%</span>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 购物车按钮 -->
    <div class="cart-button">
      <el-button
          type="danger"
          :icon="ShoppingCartFull"
          circle
          size="large"
      />
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { ShoppingCartFull } from '@element-plus/icons-vue'

const activeTime = ref('11:00')

const timeSlots = ref([
  { time: '10:00', status: '已开抢', statusClass: 'ended' },
  { time: '11:00', status: '抢购进行中', statusClass: 'active' },
  { time: '12:00', status: '即将开场', statusClass: 'coming' },
  { time: '13:00', status: '即将开场', statusClass: 'coming' }
])

const hotProducts = ref([
  { name: 'Apple iPhone 12 Pro...', price: '8888.00', bonus: '88.00', image: 'https://images.unsplash.com/photo-1551029506-0807df4e2031?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=80' },
  { name: 'Android Phone Pro...', price: '5888.00', bonus: '88.00', image: 'https://images.unsplash.com/photo-1519167758481-83f550bb49b3?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=80' },
  // 添加更多商品...
])

const products = ref([
  {
    title: '鱼跃(YUWELL)低频理疗仪 SDP-330...',
    price: '234.50',
    promotion: '海量满199减100',
    soldPercent: 29
  },
  // 添加更多商品...
])
</script>

<style scoped>
.seckill-page {
  max-width: 750px;
  margin: 0 auto;
  padding: 20px;
  background: #f5f5f5;
  min-height: 100vh;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.title {
  color: #e4393c;
  font-size: 28px;
  margin: 10px 0;
}

.time-line {
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

.time-tab {
  text-align: center;
  padding: 0 20px;
}

.time-point {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.status {
  font-size: 12px;
  &.active {
    color: #e4393c;
  }
  &.ended {
    color: #999;
  }
  &.coming {
    color: #666;
  }
}

.hot-section {
  margin: 20px 0;
  background: #fff;
  padding: 15px;
  border-radius: 8px;
}

.section-title {
  color: #e4393c;
  font-size: 18px;
  margin: 10px 0;
}

.hot-items {
  display: flex;
  gap: 15px;
  padding: 10px 0;
}

.hot-item {
  width: 160px;
  text-align: center;
  border: none;
}

.product-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.product-name {
  font-size: 14px;
  margin: 8px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.price-tag {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.price {
  color: #e4393c;
  font-size: 16px;
}

.product-list {
  margin-top: 20px;
}

.product-card {
  margin-bottom: 15px;
  border-radius: 8px;
}

.product-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
}

.product-title {
  font-size: 16px;
  font-weight: 500;
}

.promotion-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.progress {
  flex: 1;
  margin: 0 10px;
}

.sold-text {
  color: #e4393c;
  font-size: 12px;
}

.cart-button {
  position: fixed;
  right: 30px;
  bottom: 30px;
  z-index: 100;
}

.el-button--danger {
  background: #e4393c;
  border-color: #e4393c;
  box-shadow: 0 2px 6px rgba(228, 57, 60, 0.3);
}
</style>